package com.tuteng.administrator.ashospital.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.HorizontalScrollView;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.tuteng.administrator.ashospital.AdapterManger.LismxAdapter;
import com.tuteng.administrator.ashospital.JsonCallback;
import com.tuteng.administrator.ashospital.R;
import com.tuteng.administrator.ashospital.beans.Lis_jymxRequest;
import com.tuteng.administrator.ashospital.beans.Lis_jysqList;
import com.tuteng.administrator.ashospital.beans.Lis_mxBean;
import com.tuteng.administrator.ashospital.beans.Lis_mxResponse;


import java.util.List;

import static com.tuteng.administrator.ashospital.Config.GlobleConfig.APP_URL;

public class Lis_mxActivity extends  BaseActivity implements OnClickListener{
private TextView mPatientName,mPatientAge,mPatientSex,mSendDoct,mSendDept,mRepDoct,
        mRepdept,mSendTime,mRepTime,mCheckDoct,mCheckDept,mCheckTime,mIsmenz,mLczd;
private ListView mListView;
private LismxAdapter adapter;
private LinearLayout mLin1 ;
private  LinearLayout mLin2;
private LinearLayout mTitle;
private ImageButton mImageBack;
private TextView mTextTitle;
private TextView mTxtName;
private Handler myhandler=new Handler(){
        static final int MSG_PUSH_JBXX = 121;
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
  switch (msg.what){
      case MSG_PUSH_JBXX:
            Lis_jysqList mda1= (Lis_jysqList) getIntent().getSerializableExtra("info");
            mPatientName.setText(mda1.getPatientName());
            mSendTime.setText(mda1.getSendTime());
            mSendDept.setText(mda1.getSendDeptName());
            mPatientSex.setText(mda1.getSex());
            mLczd.setText(mda1.getLczd());
            mIsmenz.setText(mda1.getLx());
            mRepDoct.setText(mda1.getRepDoctName());
            mCheckDoct.setText(mda1.getCheckDoctName());
            mTxtName.setText(mda1.getRepName()+"检验报告单");
          ///  mRepTime.setText(mda1.getRepTime());
            Lis_jymxRequest request=new Lis_jymxRequest();
            request.setRepId(mda1.getRepId());

            String url=APP_URL+"/GetLismx";
            String js= JSON.toJSONString(request);
            OkGo.<Lis_mxResponse>post(url).upJson(js).execute(new JsonCallback<Lis_mxResponse>() {
                @Override
                public void onSuccess(Response<Lis_mxResponse> response) {
                    Lis_mxResponse response1=response.body();
                    if(response1.getResultCode().equals("0"))
                    {
                        List<Lis_mxBean> beans= response1.getItems();
                        adapter=new LismxAdapter(Lis_mxActivity.this,beans);
                        mListView.setAdapter(adapter);


                    }
                }
            });
            break; default:break;
        }

        }
    };
    @Override
    protected void initEnvironment() {


    }

    @Override
    protected void initViews() {
       mPatientSex=(TextView)findViewById(R.id.lis_tv_xb);
        mPatientName= (TextView)findViewById(R.id.lis_tv_brxm);
        mPatientAge=(TextView)findViewById(R.id.lis_tv_brnl);
       // mSendDoct=(TextView) findViewById(R.id.lis_tv_sjysxm);
        mRepDoct=(TextView)findViewById(R.id.lis_tv_bgys) ;
        mSendDept=(TextView) findViewById(R.id.lis_tv_brks);
        mSendTime=(TextView) findViewById(R.id.lis_tv_sqsj);
      //  mRepTime=(TextView) findViewById(R.id.lis_tv_tjssj);
        mCheckDoct=(TextView)findViewById(R.id.lis_tv_shys) ;
        mIsmenz=(TextView)findViewById(R.id.lis_tv_brzyh) ;
        mLczd=(TextView)findViewById(R.id.lis_tv_zd) ;
        mListView=(ListView) findViewById(R.id.list_lis);
        mTitle=findViewById(R.id.in_jymx_title);
        mTxtName=findViewById(R.id.tv_ls_jg_bg);
        mImageBack=(ImageButton) mTitle.findViewById(R.id.img_title_back);
        mTextTitle=(TextView)  mTitle.findViewById(R.id.tv_include_title);
        mTextTitle.setText("检验报告");
        mImageBack.setOnClickListener(this);
        myhandler.sendEmptyMessage(121);
    }

    @Override
    protected int getLayoutId() {

        return (R.layout.activity_lis1);
    }

    @Override
    public void onClick(View v) {
switch (v.getId()){
    case R.id.img_title_back:
        finish();
        break;
        default:break;
}
    }
}
